<template>
  <div>
    <h3>功能描述</h3>
    <section>
      <div v-for="(item, index) in fncList" :key="index" class="fncListItem">
        <img :src="item.icon" style="width: 34px; height: 34px" />
        <span class="fncListItemTitle">{{ item.title }}</span>
        <span class="fncListItemCon">{{ item.con }}</span>
      </div>
    </section>
    <img
      src="@/assets/img/client/solution/Group2419.png"
      style="width: 100%; height: 192px; margin-bottom: 80px"
      @click="handleBuy('count')"
    />
    <h3 style="margin: 0 0 50px 0">帮助文档</h3>
    <section>
      <div v-for="item in dataList" :key="item.helpId" class="helpListItem">
        <span class="helpListItemTitle" @click="handleDetail(item)">
          {{ item.helpName || "无" }}
        </span>
        <span
          class="helpListItemCon"
          v-for="i in item.children"
          :Key="i.helpId"
          @click="handleDetail(i)"
        >
          {{ i.helpName || "无" }}
        </span>
      </div>
    </section>
  </div>
</template>
<script setup lang="ts">
import { onMounted, ref } from "vue";
import { helpList } from "@/api/other";
import { useRouter } from "vue-router";
const router = useRouter();

const fncList = ref<any>([
  {
    icon: new URL("@/assets/img/client/fnc_icon/fnc1.png", import.meta.url).href,
    title: "计算能力",
    con: "多类型，多规格，多种实例类型，多网卡",
  },
  {
    icon: new URL("@/assets/img/client/fnc_icon/fnc2.png", import.meta.url).href,
    title: "安全防护",
    con: "全方位的安全防护，更安心使用云服务，专注业务核心的开发",
  },
  {
    icon: new URL("@/assets/img/client/fnc_icon/fnc3.png", import.meta.url).href,
    title: "存储能力",
    con: "基于分布式架构的，可弹性扩展的虚拟块存储服务；具有高数据可靠性，高I/O吞吐能力",
  },
  {
    icon: new URL("@/assets/img/client/fnc_icon/fnc4.png", import.meta.url).href,
    title: "管理平台",
    con: "提供控制台、远程终端和API等多种管理方式，给您完全管理权限",
  },
  {
    icon: new URL("@/assets/img/client/fnc_icon/fnc4.png", import.meta.url).href,
    title: "管理平台",
    con: "提供控制台、远程终端和API等多种管理方式，给您完全管理权限",
  },
  {
    icon: new URL("@/assets/img/client/fnc_icon/fnc1.png", import.meta.url).href,
    title: "计算能力",
    con: "多类型，多规格，多种实例类型，多网卡",
  },
  {
    icon: new URL("@/assets/img/client/fnc_icon/fnc2.png", import.meta.url).href,
    title: "安全防护",
    con: "全方位的安全防护，更安心使用云服务，专注业务核心的开发",
  },
  {
    icon: new URL("@/assets/img/client/fnc_icon/fnc3.png", import.meta.url).href,
    title: "存储能力",
    con: "基于分布式架构的，可弹性扩展的虚拟块存储服务；具有高数据可靠性，高I/O吞吐能力",
  },
  {
    icon: new URL("@/assets/img/client/fnc_icon/fnc4.png", import.meta.url).href,
    title: "管理平台",
    con: "提供控制台、远程终端和API等多种管理方式，给您完全管理权限",
  },
]);
const dataList = ref<any>([]);

onMounted(() => {
  getHelpList();
});


// 立即购买
const handleBuy = (type) => {
  router.push({
    path: "/client/cloudService/components/shoppingHome",
    query: { type },
  });
};

// 获取帮助中心列表
const getHelpList = () => {
  helpList({}).then((res: any) => {
    let list = <any>[];
    res.data.forEach((item: any, index: number) => {
      if (index <= 2) {
        if (item.children) {
          let temp = <any>[];
          item.children.forEach((child: any, k: number) => {
            if (k == 0) temp.push(child);
          });
          item.children = temp;
        }
        list.push(item);
      }
    });
    dataList.value = list;
  });
};

// 跳转详情
const handleDetail = (row: any) => {
  router.push({
    path: "/client/helpCenter/details",
    query: { helpId: row.helpId },
  });
};
</script>
<style lang="less" scoped>
h3 {
  width: 100%;
  text-align: center;
  margin-top: 220px;
  font-size: 39px;
  margin-bottom: 50px;
}
section {
  width: 100%;
  display: grid;
  flex-wrap: wrap;
  justify-content: space-between;
  grid-gap: 0 1px;
  grid-template-columns: repeat(auto-fill, 32%);
  .fncListItem {
    width: 100%;
    height: 200px;
    margin-bottom: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.3s;
    justify-content: space-evenly;
    padding: 0 30px;
    &:hover {
      box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
    }
    .fncListItemTitle {
      font-size: 20px;
      font-weight: 600;
    }
    .fncListItemCon {
      font-size: 16px;
      font-weight: 400;
      color: #777777;
    }
  }
  .helpListItem {
    width: 100%;
    height: 140px;
    margin-bottom: 80px;
    display: flex;
    flex-direction: column;
    align-items: left;
    padding-left: 30px;
    background: #ffffff;
    transition: all 0.5s;
    box-shadow: -5px 5px 20px 0px #e3e8f0;
    justify-content: space-evenly;
    &:hover {
      box-shadow: 0 0 5px 5px #c0cee4;
    }
    span:hover {
      cursor: pointer;
      color: #4098ff;
      text-decoration: underline;
    }
    .helpListItemTitle {
      font-size: 22px;
      font-weight: 500;
    }
    .helpListItemCon {
      font-size: 18px;
      font-weight: 400;
      color: #777777;
    }
  }
}
</style>
